package com.gopay.scheduler.job;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.gopay.common.cps.dao.cbrmb.CbRmbWildCardAssistDtlDAO;
import com.gopay.common.domain.cbrmb.internationalcard.CbRmbWildCardAssistDtl;
import com.gopay.scheduler.GopayBaseJob;
import com.gopay.scheduler.service.cbrmb.CbRmbIntlCardService;

/**
 * 国际卡对账job
 * 
 * @ClassName: CbRmbIntlCardCheckOrderJob 
 * @Description: TODO 
 * @author gd.cui 
 * @date 2017年10月30日 上午11:12:23
 */
public class CbRmbIntlCardCheckOrderJob extends GopayBaseJob {

	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Resource(name = "cbRmbIntlCardService")
	private CbRmbIntlCardService cbRmbIntlCardService;

	@Resource(name = "cbRmbWildCardAssistDtlDAO")
	private CbRmbWildCardAssistDtlDAO cbRmbWildCardAssistDtlDAO;

	@Override
	protected void doJobInternal() {

		String hql = "from CbRmbWildCardAssistDtl t where t.wildCardPayStatus in ('00','12') and t.checkCount<7";
		Map<String, Object> param = new HashMap<String, Object>();
		List<CbRmbWildCardAssistDtl> orders = cbRmbWildCardAssistDtlDAO.findByHql(hql, param);
		logger.info(String.format("international card check order size:%s", orders.size()));
		for (CbRmbWildCardAssistDtl order : orders) {
			logger.info(String.format("international card check order orderID:%s", order.getGopayOrderId()));
			cbRmbIntlCardService.checkOrder(order);
		}

	}

}
